/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package phongmodel;

/**
 *
 * @author Grzesiek
 */
public class Point3D {
    private double x;
    private double y;
    private double z;
    private double w;
    
    public Point3D(){
        this.x = 0;
        this.y = 0;
        this.z = 0;
        this.w = 1;
    }
    
    public Point3D(double x, double y, double z){
        this.x = x;
        this.y = y;
        this.z = z;
        this.w = 1;
    }
    
    public double getX(){
        return this.x;
    }
    
    public double getY(){
        return this.y;
    }
    
    public double getZ(){
        return this.z;
    }
    
    public double getW(){
        return this.w;
    }
    
    public void setX(double x){
        this.x = x;
    }
    
    public void setY(double y){
        this.y = y;
    }
    
    public void setZ(double z){
        this.z = z;
    }
    
    public void setW(double w){
        this.w = w;
    }
    
    public void normalize(){
        if (w == 0){
            System.err.println("Point3D.normalize - próba dzielenia przez 0.");
            return;
        }
        this.x = x/w;
        this.y = y/w;
        this.z = z/w;
        this.w = 1;
    }
    
    @Override
    public String toString(){
        return "P = ("+(int)x+","+(int)y+","+(int)z+","+(int)w+")";
    }
}
